﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Kevin.Framework.Validation
{
    [AttributeUsage(AttributeTargets.Property
        | AttributeTargets.Field,
        AllowMultiple = true,
       Inherited = false)]
    public sealed class FloatRangeValidatorAttribute:ValidatorAttribute
    {
        private float lowerBound;
        private float upperBound;

        /// <summary>
        /// 
        /// </summary>
        public float LowerBound
        {
            get
            {
                return lowerBound;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public Double UpperBound
        {
            get { return upperBound; }
        }

        /// <summary>
        /// DoubleRangeValidatorAttribute构造函数
        /// </summary>
        /// <param name="lowerBound">Double值下限</param>
        /// <param name="upperBound">Double值上限</param>
        public FloatRangeValidatorAttribute(float lowerBound, float upperBound)
        {
            this.lowerBound = lowerBound;
            this.upperBound = upperBound;
        }

        /// <summary>
        /// 重载基类的方法，调用DoubleRangeValidator的构造方式创建一个DoubleRangeValidator实例
        /// </summary>
        /// <param name="targetType">目标类型，在本默认实现中未使用到该参数</param>
        /// <returns>DoubleRangeValidator实例</returns>
        protected override Validator DoCreateValidator(Type targetType)
        {
            return new DoubleRangeValidator(this.lowerBound, this.upperBound, this.MessageTemplate, this.Tag);
        }
    }
}
